<%@page import="accessor.DepartmentAccessor"%>
<%@page import="accessor.Department"%>
<%@include file="header.jsp" %>
<%@include file="menubar/adminmenu.jsp" %>
<div class="break_line"></div>
<div class="break_line"></div>
<div id="content">
    <div id="title_content">UPDATE DEPARTMENT</div>
    <form method="POST" action="../update_department">
        <%
            DepartmentAccessor departmentAccessor = new DepartmentAccessor();
            int departmentID = request.getParameter("departmentID") != null ? Integer.parseInt(request.getParameter("departmentID")) : 0;
            Department department = departmentAccessor.getDepartmentByID(departmentID);
        %>
        <% if (request.getSession().getAttribute("updateError") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("updateError"));%>
                    </div>
                    <%}%>
        <input type="hidden" name="departmentID" value="<%= department != null ? department.getDepartmentID() : ""%>"/>
        <table class="form_content" width="100%">
            <tr>
                <td>DEPARTMENT NAME: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_department_name") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_department_name"));%>
                    </div>
                    <%}%>
                    <input type="text" name="department_name" class="form_input" value="<%= department != null ? department.getDepartmentName() : ""%>"/></td>
            </tr>
            <tr>
                <td>DESCRIPTION: </td>
                <td>
                    <% if (request.getSession().getAttribute("update_description") != null) {%>
                    <div class="form_error">
                        <% out.println(request.getSession().getAttribute("update_description"));%>
                    </div>
                    <%}%>
                    <input type="text" name="description" class="form_input" value="<%= department != null ? department.getDepartmentDescription() : ""%>"/>
                </td>
            </tr>
            <tr>
                <td></td>
                <td colspan="2"><input type="submit" name="submit" class="form_input" style="width: 100px;" value="Update"/></td>
            </tr>
        </table>
    </form>
</div>
<!--END content-->
<%@include file="footer.jsp" %>